from stark.service import stark
from stark.service.stark import StarkHandler, Option
from .base import PermissionHandler


class ClassListConfig(StarkHandler):
    def display_title(self, obj=None, is_header=None, *args, **kwargs):
        if is_header:
            return '班级'
        return "%s-%s期" % (obj.course, obj.semester)

    # 组合筛选
    search_group = [
        Option(field='school'),
        Option(field='course'),
    ]
    search_list = ['school__contains']

    list_display = ['school', display_title, stark.get_datetime_text("开班日期", 'start_date'), 'price',
                    'tutor',stark.get_m2m_text('老师', 'teachers')]
